/*
 * This file is part of Shopping Lists Organizer software
 *
 * Copyright (C) 2011 Denis Kvita <dkvita@gmail.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */

#ifndef SHOPPINGLISTEDITOR_H
#define SHOPPINGLISTEDITOR_H

#include <QtGui/QWidget>
#include <QDate>

class QComboBox;
class QDateEdit;
class QLabel;
class QTableView;
class QModelIndex;
class QSqlQueryModel;
class QSqlTableModel;
class QSortFilterProxyModel;
class QString;
class QToolButton;

class purchase;

class shoppingListEditor : public QWidget
{
	Q_OBJECT

signals:
	void guiControlsSwitch(bool on);

public:
	shoppingListEditor(QWidget *parent = 0);
	~shoppingListEditor();

public slots:
	void onDateChanged(const QDate& date);
	void onListNameEdited(const QString &text);
	void onListRenamed();
	void onListChanged(int index);
	void onAddPurchase();
	void onRemovePurchase();
	void onRemoveList();
	void onPrintList();
	void onTotalPlanChanged(double newTotal);
	void onTotalBuyChanged(double newTotal);
	void updateData();
	void restore();
	void onHeaderSectionShow(bool isShow);
	void saveSettings();
	void saveVisualSettings();
	void restoreVisualSettings();

protected:
	int selectedPurchase();

private:
	QDate activeListDate;
	int activeListIdx;
	QString activeListName;
	QComboBox *shopListV;
	QLabel *sumPlanV, *sumBuyV;
	QTableView *purchaseV;
	purchase *purchaseD;
	QToolButton *addPurchase, *remPurchase, *remList, *printList;
	QDateEdit *listDate;
	QSortFilterProxyModel *purchaseP;
};

#endif // SHOPPINGLISTEDITOR_H
